<template>
  <div align='center'>
    <!-- 一级 -->
    <el-form-item>
        <span>选择部门: </span>
        <el-select v-model="addPopupDepend.selectValuelev1">
          <el-option
              v-for="item in addPopupDepend.options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
          </el-option>
        </el-select>
    </el-form-item>
    <!-- 二级 -->
    <el-form-item>
        <span>选择部门: </span>
        <el-select v-model="addPopupDepend.selectValuelev2">
          <el-option
              v-for="item in addLev2Linkage"
              :key="item.value"
              :label="item.label"
              :value="item.value">
          </el-option>
        </el-select>
    </el-form-item>
  </div>
</template>
<script lang="ts">
export default {
  name:'',

  data(){
    return{
      addPopupDepend:{ // ! 添加系时需要的东西
        options: [
            {
                value: 'test1',
                label: '研发部',
                children:[{
                    value: '11',
                    label: '项目组1',
                },
                {
                    value: '12',
                    label: '项目组2',
                },
                {
                    value: '13',
                    label: '项目组3',
                },
                {
                    value: '14',
                    label: '项目组4',
                }]
            },
            {
                value: 'test2',
                label: '行政人事部',
                children:[{
                    value: '21',
                    label: '人事部',
                }]
            },
            {
                value: 'test3',
                label: '财政部',
                children:[{
                    value: '31',
                    label: '财政部',
                }]
            },
            {
                value: 'test4',
                label: '市场部',
                children:[{
                    value: '41',
                    label: '市场部',
                }]
            }
        ],
        // * 一级下拉框
        selectValuelev1:'',
        // * 二级下拉框
        selectValuelev2:'',

    },
    }
  },
  computed: {
      // * 联动
      addLev2Linkage(){
          if(this.addPopupDepend.selectValuelev1 == '') return []
          else return this.addPopupDepend.options.filter((val,index)=>{return val.value == this.addPopupDepend.selectValuelev1})[0].children
      },
  },
  methods: {
    getRole (prov) {
      let roles = []
      this.select2= []
      for (var val of allrole) {
        if (prov===val.pro) {
          console.log(val)
          roles.push({label: val.label,value: val.label})
        }
        this.options1 = roles
      }
    },
    getList (opt) {
      console.log(opt)
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
